Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bank::check_status_cache: allocate outside read lock #3394

Merged

Conversation

apfitzge
Copy link

Problem

  • Bank::check_status_cache grabs a read lock on the status cache then performs a collect (allocations).
  • This can lead to holding the lock longer than otherwise necessary

Summary of Changes

  • We know exact vector length up front
  • Allocate the vector before acquiring the read lock

Fixes #

@apfitzge
Copy link
Author

randomly stumbled upon this while looking at how we use status cache

@@ -202,8 +203,9 @@ impl Bank {
}

lock_result
})
.collect()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we previously had 2 exact sized iterators so this collect on the zip should have only been doing a single allocation.

@apfitzge apfitzge marked this pull request as ready for review October 31, 2024 15:41
@apfitzge apfitzge merged commit cec047d into anza-xyz:master Nov 1, 2024
40 checks passed
@apfitzge apfitzge deleted the status_cache_allocate_outside_lock branch November 1, 2024 14:36
kevinheavey pushed a commit to kevinheavey/agave that referenced this pull request Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants